<?php

function delete()
{
$name=$_GET["name"];
	
	//连接数据库
	$con = mysql_connect("localhost","root","");
		if (!$con)
 		 {
 		 die('Could not connect: ' . mysql_error());
		  }
		mysql_select_db("test", $con);
	$sql="select * from file where orginalname='".$name."'";
    
	$result=mysql_query($sql,$con);
	
	$row= mysql_fetch_array($result);
	
	$path=$row['path'];
	
	$sql1="delete from file where orginalname='".$name."'";
	
	$result1=mysql_query($sql1,$con);
	
	$path1=iconv("UTF-8", "GB2312",$path);
	unlink($path1);
	
	
}

delete();
header ( "Content-Type:text/html; charset=utf-8" );
echo "<script>alert('删除成功!');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
?>
